package com.clickpaas.materialsprocurement.bean;

import com.bizcloud.ipaas.t0ba0ba6afb694026b6b4e4e048af2b43.d20210202135416.codegen.*;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class ApiBean {
    /**
     * 对象名称:成本中心
     * 对象代码:CostCenter
     */
    private volatile CostcenterApi _costcenterApi;
    @Bean
    public CostcenterApi costcenterApi(){
        try {
            return getApi(CostcenterApi.class,_costcenterApi);
        } catch (Exception e) {
            return new CostcenterApi();
        }
    }

    /**
     * 对象名称:物料资料
     * 对象代码:STD_materiel
     */
    private volatile StdmaterielApi _stdmaterielApi;
    @Bean
    public StdmaterielApi stdmaterielApi(){
        try {
            return getApi(StdmaterielApi.class,_stdmaterielApi);
        } catch (Exception e) {
            return new StdmaterielApi();
        }
    }

    /**
     * 对象名称:采购订单
     * 对象代码:PurchaseOrder
     */
    private volatile PurchaseorderApi _purchaseorderApi;
    @Bean
    public PurchaseorderApi purchaseorderApi(){
        try {
            return getApi(PurchaseorderApi.class,_purchaseorderApi);
        } catch (Exception e) {
            return new PurchaseorderApi();
        }
    }

    /**
     * 对象名称:采购订单行
     * 对象代码:PurchaseLine
     */
    private volatile PurchaselineApi _purchaselineApi;
    @Bean
    public PurchaselineApi purchaselineApi(){
        try {
            return getApi(PurchaselineApi.class,_purchaselineApi);
        } catch (Exception e) {
            return new PurchaselineApi();
        }
    }

    /**
     * 对象名称:请购单行
     * 对象代码:PMS_purchaseApplyLine
     */
    private volatile PmspurchaseapplylineApi _pmspurchaseapplylineApi;
    @Bean
    public PmspurchaseapplylineApi pmspurchaseapplylineApi(){
        try {
            return getApi(PmspurchaseapplylineApi.class,_pmspurchaseapplylineApi);
        } catch (Exception e) {
            return new PmspurchaseapplylineApi();
        }
    }

    /**
     * 对象名称:共享库存
     * 对象代码:ShareWarehouse
     */
    private volatile SharewarehouseApi _sharewarehouseApi;
    @Bean
    public SharewarehouseApi sharewarehouseApi(){
        try {
            return getApi(SharewarehouseApi.class,_sharewarehouseApi);
        } catch (Exception e) {
            return new SharewarehouseApi();
        }
    }

    /**
     * 对象名称:供应商资料
     * 对象代码:SupplierInformation
     */
    private volatile SupplierinformationApi _supplierinformationApi;
    @Bean
    public SupplierinformationApi supplierinformationApi(){
        try {
            return getApi(SupplierinformationApi.class,_supplierinformationApi);
        } catch (Exception e) {
            return new SupplierinformationApi();
        }
    }

    /**
     * 对象名称:单位
     * 对象代码:Unit
     */
    private volatile UnitApi _unitApi;
    @Bean
    public UnitApi unitApi(){
        try {
            return getApi(UnitApi.class,_unitApi);
        } catch (Exception e) {
            return new UnitApi();
        }
    }

    /**
     * 对象名称:询价单行
     * 对象代码:InquiryLine
     */
    private volatile InquirylineApi _inquirylineApi;
    @Bean
    public InquirylineApi inquirylineApi(){
        try {
            return getApi(InquirylineApi.class,_inquirylineApi);
        } catch (Exception e) {
            return new InquirylineApi();
        }
    }

    /**
     * 对象名称:甄选
     * 对象代码:srm_select
     */
    private volatile SrmselectApi _srmselectApi;
    @Bean
    public SrmselectApi srmselectApi(){
        try {
            return getApi(SrmselectApi.class,_srmselectApi);
        } catch (Exception e) {
            return new SrmselectApi();
        }
    }

    /**
     * 对象名称:入库单
     * 对象代码:StockInOrder
     */
    private volatile StockinorderApi _stockinorderApi;
    @Bean
    public StockinorderApi stockinorderApi(){
        try {
            return getApi(StockinorderApi.class,_stockinorderApi);
        }catch (Exception e){
            return new StockinorderApi();
        }
    }

    /**
     * 延迟加载
     * @param clazz
     * @param cla
     * @param <T>
     * @return
     * @throws Exception
     */
    private  <T> T getApi(Class<T> clazz,T cla) throws Exception {
        if (null == cla){
            synchronized (clazz){
                if (null == cla){
                    cla = clazz.newInstance();
                }
            }
        }
        return cla;
    }
}
